package com.wjh.controller;


import com.sun.javafx.font.freetype.FTFactory;
import com.wjh.pojo.Florist;
import com.wjh.pojo.Flower;
import com.wjh.pojo.FlowerType;
import com.wjh.service.FloristService;
import com.wjh.service.FlowerService;
import com.wjh.service.FlowerTypeService;
import com.wjh.utils.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("flower")
public class FlowerController {

    @Resource
    private FlowerService flowerService;

    @Resource
    private FlowerTypeService flowerTypeService;

    @Resource
    private FloristService floristService;

    @GetMapping("/like")
    public ResponseResult likeFlower(String name){
        return flowerService.likeFlower(name);
    }


    @GetMapping("/list")
    public ResponseResult flowerList(Integer pageNum,Integer pageSize,Integer type,String flowerName){
        return flowerService.flowerList(pageNum,pageSize,type,flowerName);
    }

    @GetMapping("/type/query")
    public ResponseResult queryTypeFlower(Integer floristId,Integer typeId){
        return flowerService.queryTypeFlower(floristId,typeId);
    }

    @GetMapping("/type")
    public ResponseResult flowerType(Integer pageNum,Integer pageSize,String typeName,Integer type){
        System.err.println(pageNum);
        System.err.println(pageSize);
        return flowerTypeService.flowerType(pageNum,pageSize,typeName,type);
    }

    @PostMapping("/add")
    public ResponseResult addFlower(@RequestBody Flower flower){
        return flowerService.addFlower(flower);
    }

    @DeleteMapping("/id/{id}")
    public ResponseResult delByIds(@PathVariable("id") List<Integer> id){

        return flowerService.delByIds(id);
    }

    @GetMapping("/florist")
    public ResponseResult queryList(Integer pageNum,Integer pageSize,String name){
        return floristService.queryList(pageNum,pageSize,name);
    }

    @GetMapping("/florist/{id}")
    public Florist queryList(@PathVariable("id") Integer id){


        return floristService.queryById(id);
    }

    @PostMapping("/florist/add")
    public ResponseResult addFlorist(@RequestBody FlowerType flowerType){
        return flowerTypeService.addFlorist(flowerType);
    }
    @PostMapping("/florists/add")
    public ResponseResult addFlorists(@RequestBody Florist florist){
        return floristService.addFlorists(florist);
    }

    @DeleteMapping("/florist/{id}")
    public ResponseResult delFloristByIds(@PathVariable("id") List<Integer> id){

        return flowerTypeService.delFloristByIds(id);
    }

    @DeleteMapping("/florists/{id}")
    public ResponseResult delFloristsByIds(@PathVariable("id") List<Integer> id){
        return floristService.delFloristsByIds(id);
    }
}
